package cn.z2huo.demo.kafka.apache.official;

import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;

/**
 * <p>
 *
 * @author z2huo
 */
public class OfficialTest {

    public static void main(String[] args) {

//        "localhost:19091,localhost:19092,localhost:19093,localhost:19094,localhost:19095",
//        "127.0.0.1:19091,127.0.0.1:19092,127.0.0.1:19093,127.0.0.1:19094,127.0.0.1:19095",
//        "kafka-1:19091,kafka-2:19092,kafka-3:19093,kafka-4:19094,kafka-5:19095",
//        "kafka-1:9094,kafka-2:9094,kafka-3:9094,kafka-4:9094,kafka-5:9094",

        Producer producer = new Producer(
                "processor-producer",
                "localhost:9094",
                "test-topic",
                true,
                "tid",
                true,
                -1,
                10_000,
                null
        );

        try (KafkaProducer<Integer, String> kafkaProducer = producer.createKafkaProducer();) {
            ProducerRecord<Integer, String> record = new ProducerRecord<>("test-topic", 12, "kafka message in java 1");
            kafkaProducer.send(record);
        }

    }
}
